package com.atao.example.stream04;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 阿涛
 * @date 2021-03-07
 */
public class Test {
    public static void main(String[] args) {
        //todo reduce : 规约操作
        List<Integer> list = Arrays.asList(1,2,3,4,5,6,7,8,9,10);
        Integer count = list.stream().reduce(0, (x, y) -> x + y);
        System.out.println(count);
        System.out.println("===============================");

        //todo collect : 收集操作
        List<Integer> ageList = list.stream().collect(Collectors.toList());
        ageList.stream().forEach(System.out::println);
    }
}
